package com.xiongwei.factory;

/**
 * 简单工厂模式
 * 利用工厂类创建pizza，如果新增了pizza类只需要修改工厂类即可
 * @author XiongWei
 * @date 2024/1/9
 */
public class SimpleFactory {

    public static Pizza createPizza(String type) {
        Pizza pizza = null;
        if ("cheese".equals(type)) {
            pizza = new CheesePizza();
        } else if ("greek".equals(type)) {
            pizza = new GreekPizza();
        } else if ("pepper".equals(type)) {
            pizza = new PepperPizza();
        }
        return pizza;
    }
}
